package com.cq.hd.member.mapper;

import com.cq.hd.member.api.dto.BusinessPageDto;
import com.cq.hd.member.api.dto.BusinessPointsMallPageDto;
import com.cq.hd.member.api.dto.EnterBusinessPageDto;
import com.cq.hd.member.api.vo.*;
import com.cq.hd.member.po.TbBusinessPo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 商家表 Mapper 接口
 * </p>
 *
 * @author mYunYu
 * @since 2023-11-21
 */
@Mapper
public interface TbBusinessMapper extends BaseMapper<TbBusinessPo> {

    List<EnterBusinessPageVo> listEnterBusinessByDto(EnterBusinessPageDto enterBusinessPageDto);

    List<BusinessPageVo> listBusinessByDto(BusinessPageDto businessPageDto);

    List<BusinessPointsMallPageVo> listPointsMallBusinessByDto(BusinessPointsMallPageDto businessPointsMallPageDto);

    List<BusinessVo> listBusinessByIds(@Param("ids") List<Long> ids);

    List<BusinessVo> listByBusinessName(@Param("keyword") String keyword);

    int updateMemberExpireTime(@Param("businessId") Long businessId, @Param("memberExpireTime") LocalDateTime memberExpireTime);

    int subActiveCount(@Param("businessId") Long businessId, @Param("activeCount") Integer activeCount, @Param("now") LocalDateTime now);

    List<BusinessDetailVo> listDetailByIds(@Param("ids") List<Long> ids);

    int addSubsidyAmt(@Param("businessId") Long businessId, @Param("receiveAmt") BigDecimal receiveAmt);

    int subSubsidyAmt(@Param("businessId") Long businessId, @Param("subSubsidy") BigDecimal subSubsidy);

    // 根据邀请码，获取商家信息
    TbBusinessPo getByInviteCode(@Param("inviteCode") String inviteCode);

    int updatePosterShowAvatarState(@Param("businessId") Long businessId, @Param("posterShowAvatarState") Integer posterShowAvatarState);

    // 更新商家经纪人数量字段
    Boolean updateAgentCount(Long businessId);
}
